//== 业务流程-启动流程
let processDefinitionStartForm = function () {

    /**
     * 启动流程
     *
     * @param element {element} 启动按钮
     */
    let startProcessInstance = function (element) {
        let $form = $(element).parents('.e-form');
        EUtil.setButtonWait(element);
        if ($form != null && $form.length > 0) {
            EUtil.ajax({
                url: ETool.getBaseUrl() + 'start/process/instance/' + processDefinitionId,
                data: $form.serialize(),
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    EUtil.offButtonWait(element);
                    EUtil.ajaxErrorCallback(XMLHttpRequest, textStatus, errorThrown);
                },
                fail: function () {
                    EUtil.offButtonWait(element);
                },
                success: function (res) {
                    EUtil.offButtonWait(element);
                    ETool.successTip(commonTips.success, '流程已启动，实例ID：' + res.data);
                }
            });
        }
    };

    /**
     * 绑定事件
     */
    let bind = function () {
        $('#start-process').click(function () {
            startProcessInstance(this);
        });
    };

    return {
        //== 初始化页面
        init: function () {
            ETool.setBaseUrl(basePath + '/auth/activiti/process/definition/');
            bind();
        }
    };
}();
//== 初始化
$(document).ready(function () {
    processDefinitionStartForm.init();
});